﻿using System;
using System.Collections.Generic;
using AutoClub.Core.Domain;

namespace AutoClub.Helper.Tests
{
    /// <summary>
    /// Helps in the creation of entities for testing purposes
    /// </summary>
    public class ModelHelper
    {
        /// <summary>
        /// Creates a User Instance with its default configuration
        /// </summary>
        /// <returns></returns>
        public User CreateDefaultUser(CarCategory category)
        {
            return this.CreateDefaultUser("matiasnj@gmail.com", category);
        }

        /// <summary>
        /// Creates a Category Instance with its default configuration
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public CarCategory CreateCategory(CarCategoryEnum value)
        {
            return new CarCategory(value);
        }

        public User CreateDefaultUser(string email, CarCategory category)
        {
            return new User(email, "12345678", category);
        }

        public UserRol CreateUserRol(UserRolEnum userRolEnum)
        {
            return new UserRol(userRolEnum);
        }


        public Race CreateRace(DateTimeOffset start, DateTimeOffset end, int mechanics, CarCategoryEnum category, RaceStateEnum state)
        {
            return new Race(start, end, mechanics, new RaceState(state), new CarCategory(category));
        }

        public IList<CarCategory> CreateAllCarCategories()
        {
            IList<CarCategory> result = new List<CarCategory>();
            Array items = Enum.GetValues(typeof(CarCategoryEnum));
            for (int i = 0; i < items.Length; i++)
            {
                result.Add(new CarCategory((CarCategoryEnum)items.GetValue(i)));
            }

            return result;
        }

        public IList<RaceState> CreateAllRaceStates()
        {
            IList<RaceState> result = new List<RaceState>();
            Array items = Enum.GetValues(typeof(RaceStateEnum));
            for (int i = 0; i < items.Length; i++)
            {
                result.Add(new RaceState((RaceStateEnum)items.GetValue(i)));
            }

            return result;
        }
    }
}
